package com.ylkj.patientdrug.utils;

import android.content.Context;
import android.os.Bundle;

import com.alibaba.android.arouter.launcher.ARouter;
import com.examination.mlib.constants.ARouterConstants;
import com.examination.mlib.interfaceapi.DrugListBackApi;
import com.examination.mlib.interfaceapi.MainCallBack;

public class DrugListUtils {
    /**
     * android-rn
     * @param context
     * @param pluginId
     * @param componentName
     */
    public static void push(Context context, String pluginId, String componentName){
        DrugListBackApi drugListBackApi = (DrugListBackApi) ARouter.getInstance().build(ARouterConstants.DrugListModuleImpl).navigation();
        drugListBackApi.Android2RnPush(context,pluginId,componentName);
    }

    /**
     * rn-android
     * @param context
     * @param pluginId
     * @param componentName
     * @param bundle
     */
    public static void push(Context context, String pluginId, String componentName, Bundle bundle){
        DrugListBackApi drugListBackApi = (DrugListBackApi) ARouter.getInstance().build(ARouterConstants.DrugListModuleImpl).navigation();
        drugListBackApi.Android2RnPush(context,pluginId,componentName,bundle);
    }

    // 两次点击按钮之间的点击间隔不能少于1000毫秒
    private static final int MIN_CLICK_DELAY_TIME = 500;
    private static long lastClickTime;

    public static boolean isFastClick() {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            flag = true;
        }
        lastClickTime = curClickTime;
        return flag;
    }

    public static void getLocalAddress(MainCallBack mainCallBack){
        DrugListBackApi drugListBackApi = (DrugListBackApi) ARouter.getInstance().build(ARouterConstants.DrugListModuleImpl).navigation();
        drugListBackApi.getLocalAddress(mainCallBack);
    }

    public static String gettemporaryData(String  key){
        DrugListBackApi drugListBackApi = (DrugListBackApi) ARouter.getInstance().build(ARouterConstants.DrugListModuleImpl).navigation();
        String s = drugListBackApi.getTemporaryDataStorage().get(key);
        return s;
    }

    public static void saveLocalAddress(Context context){
        DrugListBackApi drugListBackApi = (DrugListBackApi) ARouter.getInstance().build(ARouterConstants.DrugListModuleImpl).navigation();
        drugListBackApi.saveLocalAddress(context);
    }

}
